<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>
    <title>Document</title>
    <style>
        /* #main{
            width: 300px;
            height: 300px;
            background-color: deepskyblue;
        } */


        #main{
            width: 200px;
            height: 200px;
            border: 1px solid #000;
        }
    </style>
</head>
<body>
    <div id="main"></div>

    <script>
        const oDiv = document.getElementById("main")

        //核心函数
        function center (e) {
            this.style.background = 'deepskyblue'
            console.log(111);
            console.log(e.target);
            console.log(this);
        }

        oDiv.onmouseenter = _.throttle(center , 300)

        oDiv.onmouseleave = function () {
            this.style.background = ''
        }



        /* oDiv.onmousemove = throttle(center , 300)

        //节流函数
        function throttle (fn , timer) {
            let lastTime = 0
            //真正的事件函数
            return function(e){
                let nowTime = Date.now()
                //书写看门狗
                if(nowTime - lastTime < timer) return

                lastTime = nowTime
                fn.call(this , e)
            }
        } */


    </script>
</body>
</html>